$(document).ready(function () {

	listMyFood();
	
	var html = '<a href="/dingcan/dingcan/userCenterApp.do">用户中心</a> <a href="user_orderlist.html" target="_blank" title="我的订单">我的订单</a> <a href="cart.html">购物车（'+ 0 +'）</a> <a href="/dingcan/addFood.jsp" target="_blank" title="添加食物">添加食物</a>';
	$(".RightNav").html(html);
});


function listMyFood() {
	$.ajax({
		cache:true,
		type:"GET",
		url:"/dingcan/dingcan/listMyFood.do",
		async:true,
		error:function(data) {
			alert(data);
		},
		success:function(data) {
			/*
			 * JSON object to String: JSON.stringify(obj)
			 * String to JSON: JSON.parse(str);
			 */
			var result = $.parseJSON(data).result; 
			var myfoodInfo = $("#myfoodInfo");
			var html = "";
			for(var i = 1; i <= result.length; i++) {
				var food = result[i-1];
				if(food == null) {
					continue;
				}
				
				html += '<table cellpadding="0" cellspacing="0" class="gwc_tb2" id="table'+ i +'">' + 
				'<tr>' + 
				  '<td class="tb2_td1"><input type="checkbox"  value="'+ food.foodPrice +'" name="newslist" oid='+ food.oid +' /></td>' + 
				  '<td class="tb2_td2"><a href="detailsp.html" target="_blank"><img src="'+ food.pics[0] +'"/></a></td> ' + 
				  '<td class="tb2_td3"><a href="detailsp.html" target="_blank">'+ food.foodName +'</a></td>' + 
				  '<td class="tb1_td4">￥'+ food.foodPrice +'</td> ' + 
				  '<td class="tb1_td7"><a href="/dingcan/dingcan/multDelFood.do?ids='+ food.oid +'">删除</a></td>'+
				'</tr> </table> ';
				
			}
			myfoodInfo.html(html);
			
			// 输出
			$(".gwc_tb2 input[name=newslist]").click(function () {
				GetCount();
			});
		}
	});
}